package GUI;

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.sql.Timestamp;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

import core.model.Lista;

import GUI.manager.VentanaFactory;
import GUI.manager.VentanaManager;

public class panelCrearLista extends javax.swing.JPanel implements
		ActionListener, ItemListener {
	private static final int ERROR_MESSAGE = 0;
	private static final int OK_CANCEL_OPTION = 0;
	public static String titulo;
	public static int eleccion;

	/**
	 * Creates new form panelCrearLista
	 */
	public panelCrearLista() {
		
		initComponents();
	}

	private void initComponents() {

		
		bTitulo = new javax.swing.JButton();
		bSugerencias = new javax.swing.JButton();
		bCrearLista = new javax.swing.JButton();
		bHistorial = new javax.swing.JButton();
		etiquetaNick = new javax.swing.JLabel();
		botonSalir = new javax.swing.JButton();
		panelCentro = new javax.swing.JPanel();
		bCrear = new javax.swing.JButton();
		tfTitulo = new javax.swing.JTextField();
		eTipo = new javax.swing.JLabel();
		cTipo = new javax.swing.JComboBox();
		eTitulo = new javax.swing.JLabel();
		eEmpresa = new javax.swing.JLabel();
		eSupermercado = new javax.swing.JLabel();
		cbEmpresa = new javax.swing.JComboBox();
		cbSupermercado = new javax.swing.JComboBox();
		bOpciones = new javax.swing.JButton();
		etiquetaEntrada = new javax.swing.JLabel();
		bBusqueda = new javax.swing.JButton();
		bAyuda = new javax.swing.JButton();

		setBackground(new java.awt.Color(255, 255, 255));

		bTitulo.setIcon(new javax.swing.ImageIcon(
				"src/GUI/resources/encabezadoMain.png")); // NOI18N
		bTitulo.setBorder(null);
		bTitulo.setBorderPainted(false);
		bTitulo.addActionListener(this);
		bTitulo.setBackground(new java.awt.Color(255, 255, 255));

		bSugerencias.setFont(new java.awt.Font("Lucida Handwriting", 1, 13)); // NOI18N
		bSugerencias.setIcon(new javax.swing.ImageIcon(
				"src/GUI/resources/botonSugerencias.png")); // NOI18N
		bSugerencias.setBorderPainted(false);
		bSugerencias.addActionListener(this);
		bSugerencias.setBackground(new java.awt.Color(255, 255, 255));

		bCrearLista.setBackground(new java.awt.Color(255, 255, 255));
		bCrearLista.setFont(new java.awt.Font("Lucida Handwriting", 1, 13)); // NOI18N
		bCrearLista.setIcon(new javax.swing.ImageIcon(
				"src/GUI/resources/botonCrearLista.png")); // NOI18N
		bCrearLista.setBorderPainted(false);
		bCrearLista.addActionListener(this);

		bHistorial.setBackground(new java.awt.Color(255, 255, 255));
		bHistorial.setFont(new java.awt.Font("Lucida Handwriting", 1, 13)); // NOI18N
		bHistorial.setIcon(new javax.swing.ImageIcon(
				"src/GUI/resources/botonHistorial.png")); // NOI18N
		bHistorial.setBorderPainted(false);
		bHistorial.addActionListener(this);

		etiquetaNick.setBackground(new java.awt.Color(102, 102, 102));
		etiquetaNick.setFont(new java.awt.Font("Lucida Handwriting", 1, 13)); // NOI18N
		etiquetaNick.setText(panelPrincipal.nick);
		

		botonSalir.setIcon(new javax.swing.ImageIcon(
				"src/GUI/resources/menu-salir.png")); // NOI18N
		botonSalir.setBorderPainted(false);
		botonSalir.addActionListener(this);
		botonSalir.setBackground(new java.awt.Color(255, 255, 255));

		panelCentro.setBackground(new java.awt.Color(255, 255, 255));

		bCrear.setBackground(new java.awt.Color(82, 140, 188));
		bCrear.setFont(new java.awt.Font("Lucida Handwriting", 1, 14)); // NOI18N
		bCrear.setForeground(new java.awt.Color(243, 15, 120));
		bCrear.setIcon(new javax.swing.ImageIcon(
				"src/GUI/resources/botonCrear.png")); // NOI18N
		bCrear.setBorder(null);
		bCrear.addActionListener(this);

		tfTitulo.setFont(new java.awt.Font("Calibri", 0, 13)); // NOI18N
		tfTitulo.setForeground(new java.awt.Color(102, 102, 102));

		eTipo.setBackground(new java.awt.Color(255, 255, 255));
		eTipo.setFont(new java.awt.Font("Lucida Handwriting", 1, 13)); // NOI18N
		eTipo.setForeground(new java.awt.Color(102, 102, 102));
		eTipo.setText("TIPO LISTA");
		eTipo.setToolTipText("");

		cTipo.setModel(new javax.swing.DefaultComboBoxModel(new String[] {
				"Economica", "Supermercado" }));
		cTipo.addItemListener(this);
		cTipo.setSelectedIndex(0);

		eTitulo.setBackground(new java.awt.Color(255, 255, 255));
		eTitulo.setFont(new java.awt.Font("Lucida Handwriting", 1, 13)); // NOI18N
		eTitulo.setForeground(new java.awt.Color(102, 102, 102));
		eTitulo.setText("TITULO LISTA");
		eTitulo.setToolTipText("");

		eEmpresa.setBackground(new java.awt.Color(255, 255, 255));
		eEmpresa.setFont(new java.awt.Font("Lucida Handwriting", 1, 13)); // NOI18N
		eEmpresa.setForeground(new java.awt.Color(102, 102, 102));
		eEmpresa.setText("EMPRESA");
		eEmpresa.setToolTipText("");

		eSupermercado.setBackground(new java.awt.Color(255, 255, 255));
		eSupermercado.setFont(new java.awt.Font("Lucida Handwriting", 1, 13)); // NOI18N
		eSupermercado.setForeground(new java.awt.Color(102, 102, 102));
		eSupermercado.setText("SUPERMERCADO");
		eSupermercado.setToolTipText("");


		/*
		List<String> listaEmpresasNombre = new ArrayList<String>();
		List<Empresa> empresas = (List<Empresa>) obtenerEmpresas();

		Iterator<Empresa> iterator = empresas.iterator();
		while (iterator.hasNext()) {
			Empresa empresa = iterator.next();
			listaEmpresasNombre.add(String.valueOf(empresa.getNombre()));
		}
		String[] empresasNombres = new String[listaEmpresasNombre
				.size()];
		listaEmpresasNombre.toArray(empresasNombres);
		*/

		
		
		

		cbEmpresa.setModel(new javax.swing.DefaultComboBoxModel(new String[] {
				"Item 1", "Item 2", "Item 3", "Item 4" }));

		cbEmpresa.setEnabled(false);

		cbSupermercado.setModel(new javax.swing.DefaultComboBoxModel(
				new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
		cbSupermercado.setEnabled(false);

		org.jdesktop.layout.GroupLayout panelCentroLayout = new org.jdesktop.layout.GroupLayout(
				panelCentro);
		panelCentro.setLayout(panelCentroLayout);
		panelCentroLayout
				.setHorizontalGroup(panelCentroLayout
						.createParallelGroup(
								org.jdesktop.layout.GroupLayout.LEADING)
						.add(panelCentroLayout
								.createSequentialGroup()
								.addContainerGap(71, Short.MAX_VALUE)
								.add(panelCentroLayout
										.createParallelGroup(
												org.jdesktop.layout.GroupLayout.LEADING)
										.add(org.jdesktop.layout.GroupLayout.TRAILING,
												panelCentroLayout
														.createSequentialGroup()
														.add(eTipo)
														.add(32, 32, 32)
														.add(cTipo,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
																314,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
										.add(org.jdesktop.layout.GroupLayout.TRAILING,
												panelCentroLayout
														.createParallelGroup(
																org.jdesktop.layout.GroupLayout.LEADING)
														.add(eTitulo)
														.add(panelCentroLayout
																.createSequentialGroup()
																.add(panelCentroLayout
																		.createParallelGroup(
																				org.jdesktop.layout.GroupLayout.TRAILING)
																		.add(eSupermercado)
																		.add(eEmpresa))
																.add(panelCentroLayout
																		.createParallelGroup(
																				org.jdesktop.layout.GroupLayout.LEADING)
																		.add(panelCentroLayout
																				.createSequentialGroup()
																				.add(32,
																						32,
																						32)
																				.add(panelCentroLayout
																						.createParallelGroup(
																								org.jdesktop.layout.GroupLayout.LEADING)
																						.add(cbSupermercado,
																								org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
																								314,
																								org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
																						.add(cbEmpresa,
																								org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
																								314,
																								org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
																						.add(tfTitulo,
																								org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
																								314,
																								org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
																		.add(panelCentroLayout
																				.createSequentialGroup()
																				.add(56,
																						56,
																						56)
																				.add(bCrear))))))
								.add(47, 47, 47)));
		panelCentroLayout
				.setVerticalGroup(panelCentroLayout
						.createParallelGroup(
								org.jdesktop.layout.GroupLayout.LEADING)
						.add(org.jdesktop.layout.GroupLayout.TRAILING,
								panelCentroLayout
										.createSequentialGroup()
										.add(85, 85, 85)
										.add(panelCentroLayout
												.createParallelGroup(
														org.jdesktop.layout.GroupLayout.BASELINE)
												.add(cTipo,
														org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
														org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
														org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
												.add(eTipo))
										.add(29, 29, 29)
										.add(panelCentroLayout
												.createParallelGroup(
														org.jdesktop.layout.GroupLayout.BASELINE)
												.add(eEmpresa)
												.add(cbEmpresa,
														org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
														org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
														org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
										.add(18, 18, 18)
										.add(panelCentroLayout
												.createParallelGroup(
														org.jdesktop.layout.GroupLayout.BASELINE)
												.add(eSupermercado)
												.add(cbSupermercado,
														org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
														org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
														org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
										.add(21, 21, 21)
										.add(panelCentroLayout
												.createParallelGroup(
														org.jdesktop.layout.GroupLayout.BASELINE)
												.add(eTitulo)
												.add(tfTitulo,
														org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
														org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
														org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
										.add(30, 30, 30)
										.add(bCrear,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
												39,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
										.addContainerGap(173, Short.MAX_VALUE)));

		bOpciones.setFont(new java.awt.Font("Lucida Handwriting", 1, 13)); // NOI18N
		bOpciones.setIcon(new javax.swing.ImageIcon(
				"src/GUI/resources/botonOpciones.png")); // NOI18N
		bOpciones.setBorderPainted(false);
		bOpciones.setBackground(new java.awt.Color(255, 255, 255));
		bOpciones.addActionListener(this);

		etiquetaEntrada.setFont(new java.awt.Font("Lucida Handwriting", 1, 13)); // NOI18N
		etiquetaEntrada.setForeground(new java.awt.Color(243, 15, 120));
		etiquetaEntrada.setText("BIENVENIDO A LISTA DE LA COMPRA MAKER ");

		bBusqueda.setBackground(new java.awt.Color(255, 255, 255));
		bBusqueda.setFont(new java.awt.Font("Lucida Handwriting", 1, 13)); // NOI18N
		bBusqueda.setIcon(new javax.swing.ImageIcon(
				"src/GUI/resources/botonBusqueda.png")); // NOI18N
		bBusqueda.setToolTipText("");
		bBusqueda.setBorderPainted(false);
		bBusqueda.addActionListener(this);

		bAyuda.setFont(new java.awt.Font("Lucida Handwriting", 1, 13)); // NOI18N
		bAyuda.setIcon(new javax.swing.ImageIcon(
				"src/GUI/resources/botonAyuda.png")); // NOI18N
		bAyuda.setBorderPainted(false);
		bAyuda.setBackground(new java.awt.Color(255, 255, 255));
		bAyuda.addActionListener(this);

		org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
				this);
		this.setLayout(layout);
		layout.setHorizontalGroup(layout
				.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
				.add(layout
						.createSequentialGroup()
						.add(layout
								.createParallelGroup(
										org.jdesktop.layout.GroupLayout.LEADING)
								.add(layout
										.createSequentialGroup()
										.addContainerGap()
										.add(layout
												.createParallelGroup(
														org.jdesktop.layout.GroupLayout.LEADING)
												.add(layout
														.createParallelGroup(
																org.jdesktop.layout.GroupLayout.TRAILING)
														.add(bCrearLista,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
																157,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
														.add(bBusqueda,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
																155,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
														.add(bHistorial,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
																157,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
														.add(bSugerencias,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
																157,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
														.add(bOpciones,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
																157,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
												.add(org.jdesktop.layout.GroupLayout.TRAILING,
														bAyuda,
														org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
														157,
														org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
										.add(27, 27, 27)
										.add(panelCentro,
												org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
												org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
												Short.MAX_VALUE))
								.add(layout
										.createSequentialGroup()
										.add(84, 84, 84)
										.add(etiquetaEntrada)
										.add(46, 46, 46)
										.add(etiquetaNick,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
												280,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
						.add(48, 48, 48))
				.add(layout
						.createSequentialGroup()
						.add(96, 96, 96)
						.add(bTitulo)
						.addPreferredGap(
								org.jdesktop.layout.LayoutStyle.RELATED,
								org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
								Short.MAX_VALUE).add(botonSalir)
						.addContainerGap()));
		layout.setVerticalGroup(layout
				.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
				.add(layout
						.createSequentialGroup()
						.add(6, 6, 6)
						.add(layout
								.createParallelGroup(
										org.jdesktop.layout.GroupLayout.LEADING)
								.add(bTitulo,
										org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
										104,
										org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
								.add(botonSalir))
						.add(6, 6, 6)
						.add(layout
								.createParallelGroup(
										org.jdesktop.layout.GroupLayout.LEADING)
								.add(etiquetaEntrada).add(etiquetaNick))
						.add(18, 18, 18)
						.add(layout
								.createParallelGroup(
										org.jdesktop.layout.GroupLayout.LEADING)
								.add(layout
										.createSequentialGroup()
										.add(bBusqueda,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
												41,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
										.add(18, 18, 18)
										.add(bCrearLista,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
												41,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
										.add(18, 18, 18)
										.add(bHistorial,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
												41,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
										.add(18, 18, 18)
										.add(bSugerencias,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
												41,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
										.add(18, 18, 18)
										.add(bOpciones,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
												41,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
										.add(18, 18, 18)
										.add(bAyuda,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
												41,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
								.add(panelCentro,
										org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
										org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
										org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
						.addContainerGap(
								org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
								Short.MAX_VALUE)));
	}

	private javax.swing.JButton bAyuda;
	private javax.swing.JButton bBusqueda;
	private javax.swing.JButton bCrear;
	private javax.swing.JButton bCrearLista;
	private javax.swing.JButton bHistorial;
	private javax.swing.JButton bOpciones;
	private javax.swing.JButton bSugerencias;
	private javax.swing.JButton bTitulo;
	private javax.swing.JButton botonSalir;
	private javax.swing.JComboBox cTipo;
	private javax.swing.JComboBox cbEmpresa;
	private javax.swing.JComboBox cbSupermercado;
	private javax.swing.JLabel eEmpresa;
	private javax.swing.JLabel eSupermercado;
	private javax.swing.JLabel eTipo;
	private javax.swing.JLabel eTitulo;
	private javax.swing.JLabel etiquetaEntrada;
	private javax.swing.JLabel etiquetaNick;
	private javax.swing.JPanel panelCentro;
	private javax.swing.JTextField tfTitulo;
	private int ant;
	private JFrame actual;
	private JPanel estePanel = this;

	public void actionPerformed(ActionEvent e) {

		if (e.getSource() == bSugerencias) {
			actual = (JFrame) UtilidadesGUI.getContenedorPrincipal(estePanel);
			actual.getContentPane().remove(0);
			actual.getContentPane().add(new panelSugerencias());
			actual.setPreferredSize(new Dimension(850, 630));
			actual.pack();
			actual.repaint();
			UtilidadesGUI.CentrarPantalla(actual);

		}

		if (e.getSource() == bBusqueda) {
			actual = (JFrame) UtilidadesGUI.getContenedorPrincipal(estePanel);
			actual.getContentPane().remove(0);
			actual.getContentPane().add(new panelBusqueda());
			actual.setPreferredSize(new Dimension(850, 630));
			actual.pack();
			actual.repaint();
			UtilidadesGUI.CentrarPantalla(actual);

		}

		if (e.getSource() == bHistorial) {
			actual = (JFrame) UtilidadesGUI.getContenedorPrincipal(estePanel);
			actual.getContentPane().remove(0);
			actual.getContentPane().add(new panelHistorial());
			actual.setPreferredSize(new Dimension(850, 630));
			actual.pack();
			actual.repaint();
			UtilidadesGUI.CentrarPantalla(actual);

		}
		if (e.getSource() == bOpciones) {
			actual = (JFrame) UtilidadesGUI.getContenedorPrincipal(estePanel);
			actual.getContentPane().remove(0);
			actual.getContentPane().add(new panelOpciones());
			actual.setPreferredSize(new Dimension(850, 630));
			actual.pack();
			actual.repaint();
			UtilidadesGUI.CentrarPantalla(actual);

		}
		if (e.getSource() == bAyuda) {
			actual = (JFrame) UtilidadesGUI.getContenedorPrincipal(estePanel);
			actual.getContentPane().remove(0);
			actual.getContentPane().add(new panelAyuda());
			actual.setPreferredSize(new Dimension(850, 630));
			actual.pack();
			actual.repaint();
			UtilidadesGUI.CentrarPantalla(actual);

		}
		if (e.getSource() == bTitulo) {
			actual = (JFrame) UtilidadesGUI.getContenedorPrincipal(estePanel);
			actual.getContentPane().remove(0);
			actual.getContentPane().add(new panelPrincipal());
			actual.setPreferredSize(new Dimension(850, 630));
			actual.pack();
			actual.repaint();
			UtilidadesGUI.CentrarPantalla(actual);

		}
		if (e.getSource() == bCrear) {
			titulo=tfTitulo.getText();
			System.out.println(titulo);
			
			if((tfTitulo.getText().length()==0)){
				Icon icono = new ImageIcon("src/GUI/resources/error.gif");
				JOptionPane.showOptionDialog(null,
						"Necesario introducir titulo de lista",
						"Crear lista", OK_CANCEL_OPTION, ERROR_MESSAGE, icono,
						new Object[] { "ACEPTAR" }, null);
			}else{
			
			titulo=tfTitulo.getText();
			VentanaManager ventanaManager= VentanaFactory.getInstance();
			ventanaManager.insertLista(new Lista(panelCrearLista.titulo, panelPrincipal.nick, new Timestamp(0)));

			
			if (cTipo.getSelectedItem().equals("Economica")) {
				panelHistorial.autor=1;
				eleccion = 1;
				actual = (JFrame) UtilidadesGUI
						.getContenedorPrincipal(estePanel);
				actual.getContentPane().remove(0);
				actual.getContentPane().add(new panelCrearListaEconomica(panelHistorial.autor));
				actual.setPreferredSize(new Dimension(850, 630));
				actual.pack();
				actual.repaint();
				UtilidadesGUI.CentrarPantalla(actual);
			}
			}
			if (e.getSource() == bTitulo) {
				actual = (JFrame) UtilidadesGUI
						.getContenedorPrincipal(estePanel);
				actual.getContentPane().remove(0);
				actual.getContentPane().add(new panelPrincipal());
				actual.setPreferredSize(new Dimension(850, 630));
				actual.pack();
				actual.repaint();
				UtilidadesGUI.CentrarPantalla(actual);

			}
			if (e.getSource() == botonSalir) {
				actual = (JFrame) UtilidadesGUI
						.getContenedorPrincipal(estePanel);
				actual.getContentPane().remove(0);
				actual.getContentPane().add(new panelSalir(9));
				actual.setPreferredSize(new Dimension(610, 330));
				actual.pack();
				actual.repaint();
				UtilidadesGUI.CentrarPantalla(actual);

			}
			

		}

	}

	@Override
	public void itemStateChanged(ItemEvent e) {
		if (e.getSource() == cTipo) {
			if (cTipo.getSelectedItem().equals("Supermercado")) {
				cbEmpresa.setEnabled(true);
				cbSupermercado.setEnabled(true);

			}
			if (cTipo.getSelectedItem().equals("Economica")) {
				cbEmpresa.setEnabled(false);
				cbSupermercado.setEnabled(false);

			}

		}

	}
}